struct Solution {}

fn main() {}

impl Solution {
    pub fn is_zero_array(nums: Vec<i32>, queries: Vec<Vec<i32>>) -> bool {
        let mut diff_arr: Vec<i32> = Vec::new();
        for i in nums.clone() {
            diff_arr.push(0);
        }

        for query in queries.clone() {
            diff_arr[query[0] as usize] += 1;
            if query[1] + 1 < nums.len() as i32 {
                diff_arr[(query[1] + 1) as usize] -= 1;
            }
        }

        let mut sub_array: Vec<i32> = Vec::new();
        for idx in 0..diff_arr.len() {
            if idx == 0 {
                sub_array.push(diff_arr[0]);
                continue;
            }
            sub_array.push(sub_array[idx - 1] + diff_arr[idx]);
        }

        for idx in 0..sub_array.len() {
            if nums[idx] > sub_array[idx] {
                return false;
            }
        }
        true
    }
}